home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Computer Shopper 2005 October
/
Computer Shopper 2005 October.iso
/
Toolkit
/
Enhance
/
Treesize
/
TreeSizePro-Setup.exe
/
{app}
/
tsizepro.xsl
< prev
Wrap
Extensible Markup Language
|
2005-06-07
|
12KB
|
306 lines
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="ISO-8859-1"/>
<!-- These declaration define the behavior of the size units. If you want to have a kB conversion for example, replace "$MB" with "$kB"
However, the unit identifier is printed statically. Be sure to change them, too. -->
<xsl:decimal-format decimal-separator="," grouping-separator="."/> <!-- setting decimal number format e.g.: 1.000,00 -->
<xsl:variable name="kB">1024</xsl:variable> <!-- kB divisor -->
<xsl:variable name="MB">1048576</xsl:variable> <!-- MB divisor -->
<xsl:variable name="GB">1073741824</xsl:variable> <!-- GB divisor -->
<xsl:variable name="Drivefs">#.##0,0#</xsl:variable> <!-- GB format string -->
<xsl:variable name="Folderfs">#.##0,00</xsl:variable> <!-- MB format string -->
<xsl:template match="/Root"> <!-- root template, it calls the template "main" -->
<xsl:call-template name="main" />
</xsl:template>
<xsl:template name="main"> <!-- this is the main template, it applies and calls all the other templates and thereby defines their order -->
<html>
<head>
<title>TreeSize Professional Report, <xsl:value-of select="Date" /></title>
<style type="text/css"> <!-- these are all the stylesheet definitions used in the output -->
body {font-family: Arial;} /* font of the other tags */
h1,h2,h3 {text-align:center;} /* center headlines */
table {font-family:Arial Narrow; Arial; padding:2px;} /* tree-table design */
th {border-bottom-color:#000; border-bottom-style:solid; border-bottom-width:1px;} /* line drawn on the bottom of the th's */
.box {display:none;} /* invisible div's */
.boxon {display:block;} /* visible div's */
.tree {font-family:Courier;} /* indention and '+'/'-' font */
.tabbig {width:17em; text-align:left;} /* name column */
.tab {width:6em; text-align:center;} /* size column */
.tabright {width:6em; text-align:right;} /* compression column */
</style>
<script type="text/javascript"> <!-- JavaScript functions to create tree effects view design -->
function SwitchDisplay(node) // function which changes the visibility of the div's
{
var nextnode = node.nextSibling; // get next sibling node
if (nextnode.style.display != "block") // change visibility into the opposite
{
nextnode.style.display = "block";
}
else
{
nextnode.style.display = "none";
}
SwitchTreeSymbol(node);
}
function SwitchTreeSymbol(node) // function which switches the + into - and vice versa
{
if (node.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild != null) // check if node is available
{
var targetnode = node.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild; // get suitable node (the span-tag)
s = new String(targetnode.nodeValue); // get the node's text
if ((i = s.indexOf("+")) != -1) // switch tree symbol into it's opposite
{
targetnode.nodeValue = (s.substr(0,i) + "-" + s.substr(i+1,s.length));
}
else if ((i = s.indexOf("-")) != -1)
{
targetnode.nodeValue = (s.substr(0,i) + "+" + s.substr(i+1,s.length));
}
}
}
function twodigits(n) // function which creates an extended date, e.g. "1" becomes "01"
{
if (n < 10) // if (n less than 10)
return "0" + n;
else
return n;
}
function TimeConversion(highfiletime) // converts the FileTime value into JavaScript's intern time and then into a
{
// human-readable format. However, this is not 100% accurate, because
// only the upper 32 bits of the Windows timestamp are converted.
if (highfiletime != 0)
{
highfiletime = (highfiletime - 27111902) * 429.4967296;
var javatime = new Date(highfiletime * 1000); // JavaScript's intern time: milliseconds since 01.01.1970 00:00:00
return twodigits(javatime.getDate()) + "." + twodigits((javatime.getMonth() + 1)) + "." + javatime.getFullYear();
}
else
return "N/A";
}
</script>
</head>
<body>
<xsl:call-template name="Title" /> <!-- title -->
<xsl:apply-templates select="Path" /> <!-- path -->
<xsl:call-template name="Includes" /> <!-- includes -->
<xsl:apply-templates select="ExcludePatterns" /> <!-- excludes -->
<xsl:call-template name="DriveDetails" /> <!-- drive details -->
<xsl:call-template name="FolderDetails" /> <!-- folder details -->
<xsl:call-template name="TableSetup" /> <!-- table setup (prints th's) -->
<xsl:call-template name="TreeRecursion"> <!-- tree recursion -->
<xsl:with-param name="pathpar" select="/Root/Folder" /> <!-- giving path parameter -->
</xsl:call-template>
</body>
</html>
</xsl:template>
<xsl:template name="Title">
<h1 align="center">TreeSize Professional Report, <xsl:value-of select="Date" /></h1>
</xsl:template>
<xsl:template match="Path">
<h2 align="center">
<xsl:value-of select="." />
</h2>
</xsl:template>
<xsl:template name="Includes">
<xsl:if test="(ArchiveBitFilesOnly != 0) or (CreatedPastDaysOnly != 0) or (Filter/pattern != '*')">
<h3>
Includes:
<xsl:apply-templates select="ArchiveBitFilesOnly" />
<xsl:apply-templates select="CreatedPastDaysOnly" />
<xsl:apply-templates select="Filter" />
</h3>
</xsl:if>
</xsl:template>
<xsl:template match="ArchiveBitFilesOnly">
<xsl:if test=". != 0">
Only Files created in the past.
</xsl:if>
</xsl:template>
<xsl:template match="CreatedPastDaysOnly">
<xsl:if test=". != 0">
Only Files with Archive Bit set.
</xsl:if>
</xsl:template>
<xsl:template match="Filter">
<xsl:if test="pattern != '*' ">
<xsl:value-of select="pattern" />
</xsl:if>
</xsl:template>
<xsl:template match="ExcludePatterns">
<xsl:if test="pattern">
Excludes:
<xsl:for-each select="pattern">
<xsl:value-of select="." />
<xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:template>
<xsl:template name="DriveDetails">
<h3>
Drive:
<xsl:apply-templates select="UsedBytesOnDrive" />
<xsl:apply-templates select="FreeBytesOnDrive" />
<xsl:apply-templates select="BytesPerCluster" /> Bytes
Filesystem: (<xsl:apply-templates select="Filesystem" />)
</h3>
</xsl:template>
<xsl:template match="UsedBytesOnDrive"> <!-- drive size -->
Size: <xsl:value-of select="format-number(. div $GB,$Drivefs)" /> GB
</xsl:template>
<xsl:template match="FreeBytesOnDrive"> <!-- free size on drive -->
Free: <xsl:value-of select="format-number(. div $GB,$Drivefs)" /> GB
</xsl:template>
<xsl:template match="BytesPerCluster"> <!-- bytes per cluster -->
Bytes per Cluster:
<xsl:value-of select="." />
</xsl:template>
<xsl:template match="Filesystem"> <!-- used filesystem -->
<xsl:value-of select="." />
</xsl:template>
<xsl:template name="FolderDetails"> <!-- details of the folder, which was scanned -->
<h3>
This Folder:
<xsl:apply-templates select="Folder/SizeData" />
</h3>
</xsl:template>
<xsl:template match="SizeData"> <!-- size data of scanned folder -->
Size: <xsl:value-of select="format-number(@Size div $MB,$Folderfs)" /> MB <!-- formatting numbers -->
Allocated: <xsl:value-of select="format-number(@Allocated div $MB,$Folderfs)" /> MB
Wasted: <xsl:value-of select="format-number(@Wasted div $MB,$Folderfs)" /> MB
Files: <xsl:value-of select="@Files" />
Folders: <xsl:value-of select="@Folders" />
Compression:
<xsl:if test="@Compression = 0">Yes</xsl:if> <!-- compression -->
<xsl:if test="@Compression = 1">No</xsl:if>
</xsl:template>
<xsl:template name="TableSetup"> <!-- prints the table header -->
<br />
<table align="center" cellspacing="0">
<tr>
<th class="tabbig">Name:</th>
<th class="tabright">Size:</th>
<th class="tabright">Allocated:</th>
<th class="tabright">Wasted:</th>
<th class="tabright">Files:</th>
<th class="tabright">Folders:</th>
<th class="tabright">Last Change:</th>
<th class="tab">Compression:</th>
</tr>
</table>
</xsl:template>
<xsl:template name="TreeRecursion"> <!-- creates the tree structure -->
<xsl:param name="pathpar" />
<div>
<div onClick="SwitchDisplay(this);">
<xsl:if test="$pathpar != /Root/Folder">
<xsl:call-template name="DescendantsSizeData">
<xsl:with-param name="pathpar" select="." />
</xsl:call-template>
</xsl:if>
</div>
<xsl:variable name="showmode">
<xsl:choose>
<xsl:when test="$pathpar = /Root/Folder">boxon</xsl:when>
<xsl:otherwise>box</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<div class="{$showmode}">
<xsl:for-each select="$pathpar/Folder">
<xsl:call-template name="TreeRecursion">
<xsl:with-param name="pathpar" select="." />
</xsl:call-template>
</xsl:for-each>
</div>
</div>
</xsl:template>
<xsl:template name="DescendantsSizeData"> <!-- prints the size data row of the current folder -->
<xsl:param name="pathpar" />
<table align="center" cellspacing="0">
<tr>
<xsl:variable name="indentname">
<xsl:call-template name="strlengthcheck"><xsl:with-param name="indention" select="count(ancestor::Folder)-1" /><xsl:with-param name="pathpar" select="$pathpar" /></xsl:call-template>
</xsl:variable>
<xsl:variable name="fullname" select="$pathpar/Name"></xsl:variable>
<td class="tabbig" title="{$fullname}">
<span class="tree">
<xsl:call-template name="IndentRecursiveLoop">
<xsl:with-param name="counter" select="count(ancestor::Folder)-1" />
</xsl:call-template>
</span>
<xsl:value-of select="$indentname" />
</td>
<td class="tabright"><xsl:value-of select="format-number($pathpar/SizeData/@Size div $MB,$Folderfs)" /> MB</td> <!-- formatting numbers -->
<td class="tabright"><xsl:value-of select="format-number($pathpar/SizeData/@Allocated div $MB,$Folderfs)" /> MB</td>
<td class="tabright"><xsl:value-of select="format-number($pathpar/SizeData/@Wasted div $MB,$Folderfs)" /> MB</td>
<td class="tabright"><xsl:value-of select="$pathpar/SizeData/@Files" /></td>
<td class="tabright"><xsl:value-of select="$pathpar/SizeData/@Folders" /></td>
<xsl:variable name="accesstime" select="$pathpar/LastChangeDate/@High"/>
<xsl:variable name="uid" select="generate-id($pathpar)" /> <!-- generating unique id -->
<td class="tabright" id="{$uid}">
</td>
<script type="text/javascript">
//var mytdtext = "<xsl:value-of select="$accesstime" />";
document.getElementById("<xsl:value-of select="$uid" />").firstChild.nodeValue = TimeConversion(<xsl:value-of select="$accesstime" />);
</script>
<td class="tab">
<xsl:if test="$pathpar/SizeData/@Compression = 0">Yes</xsl:if> <!-- compression -->
<xsl:if test="$pathpar/SizeData/@Compression = 1">No</xsl:if>
</td>
</tr>
</table>
</xsl:template>
<xsl:template name="strlengthcheck"> <!-- cuts too long names and adds "..." -->
<xsl:param name="indention" />
<xsl:param name="pathpar" />
<xsl:choose>
<xsl:when test="(string-length($pathpar/Name) + $indention) >= 28">
<xsl:value-of select="substring($pathpar/Name,1,(25-$indention))" />...
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$pathpar/Name" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="IndentRecursiveLoop"> <!-- makes indention used to make the tree hierarchy visible -->
<xsl:param name="counter" />
<xsl:choose>
<xsl:when test="$counter > 0">
<xsl:call-template name="IndentRecursiveLoop">
<xsl:with-param name="counter" select="($counter)-1" />
</xsl:call-template>
</xsl:when>
<xsl:when test="count(./Folder)">
+
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>